<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>支出-展示</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <link rel="stylesheet" href="./css/jquery.dataTables.min.css">

    <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/jquery.min.js"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>

    <!--[if lt IE 9]>
    <script type="text/javascript" src="./js/ie/html5.min.js"></script>
    <script type="text/javascript" src="./js/ie/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="x-nav">
            <span class="layui-breadcrumb">

            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
    </a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">

        <div class="layui-col-md12">

            <div class="layui-card">

                <div class="layui-card-body ">
                    <div class="layui-collapse" lay-filter="test">
                        <div class="layui-colla-item">
                            <h2 class="layui-colla-title">条件筛选<i class="layui-icon layui-colla-icon"></i></h2>
                            <div class="layui-colla-content">
                                <form class="layui-form" action="selectByExampleCostdetails" method="post">

                                </form>

                            </div>
                        </div>
                    </div>
                </div>

                <div class="layui-card-header">
                    <button class="layui-btn" onclick="xadmin.open('添加支出信息','goToAdminUserAddNokey',800,600)">
                        <i class="layui-icon"></i>添加
                    </button>
                </div>
                <div class="layui-card-body ">
                    <table class="layui-table layui-form" id="myTable">
                        <thead>
                        <tr>
                            <th>序号</th>
                            <th>用户id</th>
                            <th>状态</th>
                            <th>账号</th>
                            <th>密码</th>
                            <th>姓名</th>
                            <th>等级</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tfoot>
                        <tr>
                            <th>序号</th>
                            <th>用户id</th>
                            <th>状态</th>
                            <th>账号</th>
                            <th>密码</th>
                            <th>姓名</th>
                            <th>等级</th>
                            <th>操作</th>
                        </tr>
                        </tfoot>
                    </table>
                </div>

            </div>
        </div>
    </div>
</div>
</body>

<script>
    $(document).ready(function () {
        $('#myTable').DataTable({
            //加载进度提示(默认：false)
            "bProcessing": true,
            //更改显示记录数选项(默认：[10,25,50,100])
            "aLengthMenu": [15, 25, 50, 100],
            // 国际化
            language: {
                "sProcessing": "处理中...",
                "sLengthMenu": "显示 _MENU_ 项结果",
                "sZeroRecords": "没有匹配结果",
                "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
                "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
                "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
                "sInfoPostFix": "",
                "sSearch": "搜索:",
                "sUrl": "",
                "sEmptyTable": "表中数据为空",
                "sLoadingRecords": "载入中...",
                "sInfoThousands": ",",
                "oPaginate": {
                    "sFirst": "首页",
                    "sPrevious": "上页",
                    "sNext": "下页",
                    "sLast": "末页"
                },
                "oAria": {
                    "sSortAscending": ": 以升序排列此列",
                    "sSortDescending": ": 以降序排列此列"
                }
            },
            ajax: {
                url: '/adminuserlist',
                type: 'POST'
            },
            columns: [
                {
                    "data": null,
                    "render": function (data, type, row, meta) {

                        return meta.row + 1;//data.userId
                    }
                },
                {
                    "data": null,
                    "render": function (data, type, row, meta) {

                        return data.id;//data.userId
                    }
                },
                {
                    "data": null,
                    "render": function (data, type, row, meta) {

                        return data.valid;//data.userId
                    }
                },
                {
                    "data": null,
                    "render": function (data, type, row, meta) {

                        return data.nameLogin;//data.userId
                    }
                },
                {
                    "data": null,
                    "render": function (data, type, row, meta) {

                        return data.password;//data.userId
                    }
                },
                {
                    "data": null,
                    "render": function (data, type, row, meta) {

                        return data.nameUser;//data.userId
                    }
                },
                {
                    "data": null,
                    "render": function (data, type, row, meta) {

                        return data.jurisdiction;//data.userId
                    }
                },
                {
                    "data": null,
                    "sClass": "td-manage",
                    "render": function (data, type, row, meta) {
                        /*
                        <a title='编辑' onclick='xadmin.open('支出信息修改','goToCostdetailsEditByKey?id=1')' href='javascript:;'> <i class='layui-icon'>&#xe642;</i></a>
                         */
                        return '<a title="编辑" onclick="xadmin.open(\'支出信息修改\',\'goToCostdetailsEditByKey?id=' + data.id + '\')" href="javascript:;"><i class="layui-icon">&#xe642;</i></a>' +
                            '<a title="删除" onclick="member_del(this,\'' + data.id + '\')" href="javascript:;"><i class="layui-icon">&#xe640;</i></a>';
                    }
                },
            ]
        });
    });
</script>
<script>
    /*用户-删除*/
    function member_del(obj, id) {
        layer.confirm(id, function (index) {
            //发异步删除数据
            $(obj).parents("tr").remove();
            //costdetails-edit-delete
            $.ajax({
                type: "post",
                url: "/deleteCostdetailsByKey",
                data: {id: id},
                dataType: 'json',//dataType:"json",使得返回来的数据格式为json 如果不 添加该条属性，则返回来的为字符串
                success: function (data) {
                    // console.log(data["num"]) //取值可以.key值
                    // console.log(data["age"]) //取值可以.key值
                    // console.log(data["peer"]) //取值可以.key值
                },
                error: function (data) {
                    console.log("error");
                    console.log(data)
                }
            });
            layer.msg('已删除!' + id, {icon: 1, time: 1000});
        });
    }
</script>

</html>